(function() {
    var sigupBtn = document.getElementById('submit-btn');
    eleAddEvent(sigupBtn, 'click', function(e) {
        e.preventDefault();
        var name = document.getElementById('name').value;
        var sex = document.getElementById('sex').value;
        var grade = document.getElementById('grade').value;
        var area = document.getElementById('area').value;
        var department = document.getElementById('department').value;
        var phone = document.getElementById('phone').value;
        var email = document.getElementById('email').value;
        var phoneReg = /^(((13[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
        var mailReg = /^[^\._-][\w\.-]+@([A-Za-z0-9]+\.)+[A-Za-z]+$/;
        if (!phoneReg.test(phone)) {
            alert('手机号不合法');
            return;
        }
        if (!mailReg.test(email)) {
            alert('邮箱不合法');
            return;
        }
        new Ajax({
            url: '/signup',
            method: 'post',
            data: { name: name, sex: sex, grade: grade, area: area, department: department, phone: phone, email: email },
            success: function(data) {
                if (data['success']) {
                    alert(data['message']);
                } else {
                    alert(data['message']);
                }
            },
            error: function(data) {
                console.log(data);
            }
        }).send();

    })

})()